Lab 4 Part 1 Modify sim5.c to accept zero to three command line arguments. 1. The first command line argument (e.g. sim5 100 < code.sim5) overrides the value of MAXCNT. 2. The second command line argument (e.g. sim5 100 50 < code.sim5) overrides MAXCNT and delays printing the trace output until the 50th instruction is executed. 3. The third command line argument (e.g. sim5 100 50 75) overrides MAXCNT and only traces the 50th to the 75th instruction executed. Your sim5.c program comments might appear as follows: /* sim5.c add push, pop, call, ret to sim4 */ /* Last modified on September 13, 2012 */ /* usage "sim5 < test.sim5" up to 100 cycles with trace */ /* usage "sim5 1000 < test.sim5" up to 1000 cycles with trace */ /* usage "sim5 1000 800 900 < test.sim5" up to 1000 cycles trace 800 to 900 */ /* usage "sim5 1000 0 0 < test.sim5" up to 1000 cycles with no trace */ You should print error messages for illegal command line arguments such as sim5 test.sim5 sim5 a b c < test.sim5 sim5 100 200 300 < test.sim5 sim5 500 300 200 < test.sim5 Part 2 The following main program reads two integers and prints their product using function mult() to perform the multiplication. main: in %r1 in %r2 lda mult call %r0 out %r0 halt mult: clr %r0 loop: skeq %r1 ret addr %r2,%r0 dec %r1 jmp loop 1. The following main program reads a single integer (n) and prints factorial n. Write function %r0=fact(%r1) to complete the program. Your fact() function must call function %r0=mult(%r1,%r2) to do the multiplication. main: in %r1 ldi fact call %r0 out %r0 halt fact: ... ... mult: ... ... 2. Rewrite problem (1) making function %r0=fact(%r1) a recursive function. (Function fact() must still call mult() to perform the multiplication). Note that anything in in registers %r0 to %r9 before fact() calls itself is likely to disappear before the return (the called version of fact will use the same registers. Use the stack (push and pop) to store any needed register values.